import 'package:dala_flutter/dala/pages/tabs/detailcom.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

class MatePage extends StatelessWidget {
  const MatePage({
    Key? key,
  });

  @override
  Widget build(BuildContext context) {
    var mediaQuery = MediaQuery.of(context); // 获取屏幕尺寸信息
    var topPadding = mediaQuery.padding.top; // 获取刘海的顶部安全区域
    var mediaWidth = mediaQuery.size.width; // 获取屏幕宽度

    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Slidable Example',
        home: Scaffold(
            body: Padding(
          padding: EdgeInsets.fromLTRB(0, topPadding, 0, 0),
          child: Column(children: [
            Container(
              padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
              width: mediaWidth,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  IconButton(
                    onPressed: () {},
                    icon: const Icon(Icons.menu),
                    color: const Color(0xffd5a982),
                  ),
                  SizedBox(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        IconButton(
                          onPressed: () {},
                          icon: const Icon(Icons.search),
                          color: const Color(0xffd5a982),
                        ),
                        IconButton(
                          onPressed: () {},
                          icon: const Icon(Icons.camera_alt_outlined),
                          color: const Color(0xffd5a982),
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Expanded(
              child: ListView(
                children: [
                  Slidable(
                    endActionPane: const ActionPane(
                      extentRatio: 0.8,
                      motion: ScrollMotion(),
                      children: [
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(255, 92, 164, 236),
                          foregroundColor: Colors.white,
                          label: '置顶',
                        ),
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(162, 242, 170, 4),
                          foregroundColor: Colors.white,
                          label: '免打扰',
                        ),
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(255, 240, 3, 27),
                          foregroundColor: Colors.white,
                          label: '删除',
                        ),
                      ],
                    ),
                    child: ListTile(
                      onTap: () {
                        Navigator.of(context).push(
                          MaterialPageRoute(
                            builder: (context) => detailcom(),
                          ),
                        );
                      },
                      leading: Container(
                          child: ClipRRect(
                        borderRadius:
                            const BorderRadius.all(Radius.circular(10.0)),
                        child: Image.network(
                          "https://gd-hbimg.huaban.com/c046f4f7f9bf38d2b93ab146138126142e8d14931e930-adLhbn_fw236",
                          width: 40,
                          height: 40,
                        ),
                      )),
                      title: const Text('暗恋对象'),
                      subtitle: const Text('今晚有时间吗？'),
                      trailing: Container(
                          padding: const EdgeInsets.all(0),
                          child: Column(
                            children: [
                              const SizedBox(
                                height: 8,
                              ),
                              const Text("19:01"),
                              const SizedBox(
                                height: 8,
                              ),
                              Container(
                                width: 16, // 矩形的宽度
                                height: 16, // 矩形的高度
                                decoration: const BoxDecoration(
                                  color: Colors.red, // 矩形的颜色
                                  borderRadius: BorderRadius.all(
                                      Radius.circular(100)), // 可选：设置圆角
                                ),
                                alignment: Alignment.center,
                                child: const Text(
                                  "1",
                                  style: TextStyle(color: Colors.white),
                                ),
                              ),
                            ],
                          )),
                    ),
                  ),
                  const Divider(height: 1, indent: 65, endIndent: 5),
                  Slidable(
                    endActionPane: const ActionPane(
                      extentRatio: 0.8,
                      motion: ScrollMotion(),
                      children: [
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(255, 92, 164, 236),
                          foregroundColor: Colors.white,
                          label: '置顶',
                        ),
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(162, 242, 170, 4),
                          foregroundColor: Colors.white,
                          label: '免打扰',
                        ),
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(255, 240, 3, 27),
                          foregroundColor: Colors.white,
                          label: '删除',
                        ),
                      ],
                    ),
                    child: ListTile(
                      onTap: () => doNothing,
                      leading: Container(
                          child: ClipRRect(
                        borderRadius:
                            const BorderRadius.all(Radius.circular(10.0)),
                        child: Image.network(
                          "https://gd-hbimg.huaban.com/c046f4f7f9bf38d2b93ab146138126142e8d14931e930-adLhbn_fw236",
                          width: 40,
                          height: 40,
                        ),
                      )),
                      title: const Text('暗恋对象'),
                      subtitle: const Text('今晚有时间吗？'),
                      trailing: Container(
                          padding: const EdgeInsets.all(0),
                          child: Column(
                            children: [
                              const SizedBox(
                                height: 8,
                              ),
                              const Text("19:01"),
                              const SizedBox(
                                height: 8,
                              ),
                              Container(
                                width: 16, // 矩形的宽度
                                height: 16, // 矩形的高度
                                decoration: const BoxDecoration(
                                  color: Colors.red, // 矩形的颜色
                                  borderRadius: BorderRadius.all(
                                      Radius.circular(100)), // 可选：设置圆角
                                ),
                                alignment: Alignment.center,
                                child: const Text(
                                  "1",
                                  style: TextStyle(color: Colors.white),
                                ),
                              ),
                            ],
                          )),
                    ),
                  ),
                  const Divider(height: 1, indent: 65, endIndent: 5),
                  Slidable(
                    endActionPane: const ActionPane(
                      extentRatio: 0.8,
                      motion: ScrollMotion(),
                      children: [
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(255, 92, 164, 236),
                          foregroundColor: Colors.white,
                          label: '置顶',
                        ),
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(162, 242, 170, 4),
                          foregroundColor: Colors.white,
                          label: '免打扰',
                        ),
                        SlidableAction(
                          flex: 2,
                          onPressed: doNothing,
                          backgroundColor: Color.fromARGB(255, 240, 3, 27),
                          foregroundColor: Colors.white,
                          label: '删除',
                        ),
                      ],
                    ),
                    child: ListTile(
                      onTap: () => doNothing,
                      leading: Container(
                          child: ClipRRect(
                        borderRadius:
                            const BorderRadius.all(Radius.circular(10.0)),
                        child: Image.network(
                          "https://gd-hbimg.huaban.com/c046f4f7f9bf38d2b93ab146138126142e8d14931e930-adLhbn_fw236",
                          width: 40,
                          height: 40,
                        ),
                      )),
                      title: const Text('暗恋对象'),
                      subtitle: const Text('今晚有时间吗？'),
                      trailing: Container(
                          padding: const EdgeInsets.all(0),
                          child: Column(
                            children: [
                              const SizedBox(
                                height: 8,
                              ),
                              const Text("19:01"),
                              const SizedBox(
                                height: 8,
                              ),
                              Container(
                                width: 16, // 矩形的宽度
                                height: 16, // 矩形的高度
                                decoration: const BoxDecoration(
                                  color: Colors.red, // 矩形的颜色
                                  borderRadius: BorderRadius.all(
                                      Radius.circular(100)), // 可选：设置圆角
                                ),
                                alignment: Alignment.center,
                                child: const Text(
                                  "1",
                                  style: TextStyle(color: Colors.white),
                                ),
                              ),
                            ],
                          )),
                    ),
                  ),
                  const Divider(height: 1, indent: 65, endIndent: 5),
                ],
              ),
            )
          ]),
        )));
  }
}

void doNothing(BuildContext context) {}
